<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
    <script>
        var num = Math.random()

        // 0-10之间的随机数
        console.log(Math.round(num*10));

        console.log(Math.ceil(num*10));

        console.log(Math.floor(num*11));
        // 0-20
        console.log(Math.floor(num*21));

        // 获取0-x 之间的随机数
        // console.log(Math.random*(x+1));

    </script>
</body>
</html>